<?php
//var_dump($_POST);
if($_POST['1'] !== $_POST['2'])
{
    echo '<div class="alert alert-danger"><h4>Password does not match. Please repeat.</h4></div>';
    require_once 'registration.php';
} elseif($_POST['1'] === $_POST['2']) {
    $user = new Models_User();
    $valid = $user->validate($_POST);
    if($valid)
    {
        echo '<div class="alert alert-danger"><ul>';
        foreach ($valid as $value) 
        {
            echo '<li><h4>' . $value . '</h4></li>';
        }
        echo '</ul></div>';
        require_once 'registration.php';
    } else {
        $user->addNewUser($_POST);
        echo '<div class="alert alert-success">Successful.</div>';
    }
} else {
    echo '<div class="alert alert-danger"><h4>Something wrong. Please, inform administrator.</h4></div>';
}
?>
